package com.uchengwang.ui.cm_ui.me.presenter;

import android.app.Activity;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;

import com.alibaba.fastjson.JSONObject;
import com.uchengwang.functions.http.config.AccountConfig;
import com.uchengwang.functions.http.config.BaseConfig;
import com.uchengwang.functions.http.config.ClubConfig;
import com.uchengwang.functions.http.config.UCityConfig;
import com.uchengwang.functions.http.config.UUConfig;
import com.uchengwang.functions.http.config.UserConfig;
import com.uchengwang.functions.http.entity.MapRequest;
import com.uchengwang.functions.http.listener.HttpCallBack;
import com.uchengwang.functions.http.listener.IHttpManager;
import com.uchengwang.functions.http.listener.OnHttpResultListener;
import com.uchengwang.functions.http.listener.OnHttpResultSingleListener;
import com.uchengwang.functions.http.listener.OnResultListener;
import com.uchengwang.functions.http.manager.HttpManager;
import com.uchengwang.ui.UChengApplication;
import com.uchengwang.ui.base_ui.basefm.FragmentUMe;
import com.uchengwang.ui.cm_ui.login.bean.UserBean;
import com.uchengwang.ui.cm_ui.me.bean.LinkAccountBean;
import com.uchengwang.ui.cm_ui.me.bean.RecruitUnreadBean;
import com.uchengwang.ui.cm_ui.rychat.manager.RongChatManager;
import com.uchengwang.ui.cm_ui.ucity.cityBean.BaseBean;
import com.uchengwang.ui.cm_ui.ucity.cityBean.GroupBean;
import com.uchengwang.ui.cm_ui.ucity.cityBean.UcityBean;
import com.uchengwang.ui.cm_ui.ucity.cityBean.UcityInfoBean;
import com.uchengwang.ui.cm_ui.ucity.cityBean.UserBeanList;
import com.uchengwang.ui.cm_ui.umsg.bean.ClubListBean;
import com.uchengwang.ui.cm_ui.umsg.bean.SchoolClubBean;
import com.uchengwang.ui.cm_ui.uu.bean.SpeekMsgBean;
import com.uchengwang.ui.cm_ui.uu.bean.SpeekMsgListBean;
import com.uchengwang.ui.utils.DialogUtils;
import com.uchengwang.ui.utils.JsonUtils;
import com.uchengwang.ui.utils.LoadingUtils;
import com.uchengwang.ui.utils.MD5;
import com.uchengwang.ui.utils.MapKeyObjectUtils;
import com.uchengwang.ui.utils.UCommonUtil;

import java.util.ArrayList;
import java.util.List;

import io.rong.imlib.model.Conversation;


/**
 * Created by U城网 on 2017/6/19.
 */

public class HttpMeManager {

    public static HttpMeManager presenter;
    private boolean isAllow = true;

    private HttpMeManager(){}

    public static HttpMeManager getPresenter() {
        if (presenter == null){
            presenter = new HttpMeManager();
        }
        return presenter;
    }

    /**
     * 关注某人 组织
     * @param id 想要关注或者取消关注某人/社团的ID
     *           @param isAtten 是否是取消关注 true关注
     * */
    public void addAtten (final Activity activity, final boolean isAtten, final long id, final AttenListener listener){
        if (UCommonUtil.getUtil().isNeedLogin(activity, false)){
            return;
        }

        if (!isAtten){
            //取消关注提示
            DialogUtils.getUtils().showDialogSingle(activity, "确定取消关注?", "确定", new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    DialogUtils.getUtils().cancel();
                    atten(activity, isAtten, id, listener);
                }
            });
        }else {
            atten(activity, isAtten, id, listener);
        }
    }
    /**
     * 关注 取消关注
     * */
    private void atten(final Activity activity, boolean isAtten, final long id, final AttenListener listener){
        if (!isAllow){
            return;
        }
        isAllow = false;
        IHttpManager.RequestMethod method = null;
        String url = "";

        MapRequest map = new MapRequest();
        map.put(BaseConfig.ID, id);
        if (isAtten){
            method = UserConfig.UserFollow.method_follow;
            url = UserConfig.UserFollow.URL;
        }else {
            method = UserConfig.UserFollow.method_delete;
            url = UserConfig.UserFollow.URL;
        }
        LoadingUtils.getUtils().loading(activity);
        HttpManager.newInstance(activity).query(method, url, map, new HttpCallBack() {
            @Override
            public void onError(int status, String msg) {
                Log.d("jjf", "status="+status+"=msg="+msg);
                isAllow = true;
                LoadingUtils.getUtils().hide();
                listener.atten(-1);

            }

            @Override
            public void onResp(int status, String msg, String data) {
                Log.d("jjf", "status="+status+"=msg="+msg+"=data="+data);
                isAllow = true;
                LoadingUtils.getUtils().hide();
                if (status ==0){
                    FragmentUMe.isRefresh = true;//关注成功 刷新我的界面
                }
                listener.atten(status);
                if (!TextUtils.isEmpty(data)){
                    JSONObject jsonObject = JsonUtils.getManager().getJSONObject(data);
                    if (jsonObject != null){
                        String type = jsonObject.getString(BaseConfig.TYPE);
                        switch (type){
                            case "friends":
                                RongChatManager.getUtils().sendTextMsg("我们已经互相关注了，一起聊聊吧", id, Conversation.ConversationType.PRIVATE);
                                break;
                            case "newFans":

                                break;
                        }
                    }


                }
            }
        });
    }

    /**
     * 获取我的粉丝 关注 好友数量 关注除了校吧
     * */
    public void checkMyCount(Activity activity, final CheckMyCountListener listener){
        HttpManager.newInstance(activity).query(UserConfig.CheckMyCount.method, UserConfig.CheckMyCount.URL, null, new HttpCallBack() {
            @Override
            public void onError(int status, String msg) {

            }

            @Override
            public void onResp(int status, String msg, String data) {
                if (status ==0 && !TextUtils.isEmpty(data)){
                    JSONObject object = JsonUtils.getManager().getJSONObject(data);
                    int fansNum = object.getIntValue("fans");
                    int followNum = object.getIntValue("follows");
                    int friendNum = object.getIntValue("friends");
                    listener.onResult(fansNum, followNum, friendNum);
                }
            }
        });

    }


    /**
     * 获取一个人粉丝
     * @param cardType 身份类型 1-普通学生，2-社团，3-uni 0获取全部
     * */
    public void getFans(Activity activity, long uid, int page, int perpage, int cardType, UsersListener listener){
        getFriends(activity, uid, page, perpage, 1,cardType,  listener);
    }

    /**
     * 获取一个人的关注
     * @param cardType 身份类型 1-普通学生，2-社团，3-uni 0获取全部
     * */
    public void getFollows(Activity activity, long uid, int page, int perpage, int cardType, UsersListener listener){
        getFriends(activity, uid, page, perpage, 2, cardType, listener);
    }

    /**
     * 获取我的好友 别人的好友获取不到
     * @param cardType 身份类型 1-普通学生，2-社团，3-uni 0获取全部
     * */
    public void getFriend(Activity activity, int page, int perpage, int cardType, UsersListener listener){
        getFriends(activity, 0, page, perpage, 3,cardType, listener);
    }


    /**
     * 获取一个人的粉丝 好友 关注
     * @param type 1粉丝 2关注 3好友
     * @param cardType 身份类型 1-普通学生，2-社团，3-uni 0获取全部
     * @param uid 获取关注 粉丝时,必须传 获取好友时, 可传0
     * */
    public void getFriends(Activity activity, long uid, int page, int perpage, int type, int cardType,  final UsersListener listener){
        IHttpManager.RequestMethod method = null;
        String url = "";
        switch (type){
            case 1://1粉丝  2关注
                method = UserConfig.UserFans.method;
                url = UserConfig.UserFans.URL;
                break;
            case 2:
                method = UserConfig.UserFollow.method_check;
                url = UserConfig.UserFollow.URL;
                break;
            case 3://好友
                method = UserConfig.UserFriends.method;
                url = UserConfig.UserFriends.URL;
                break;
        }

        MapRequest map = new MapRequest();
        if (uid >0){
            map.put(BaseConfig.CHECK_ID, uid);
        }

        if (cardType >0){
            map.put(BaseConfig.USER_ROLE, cardType);//不传就是获取一个类别全部的
        }
        map.put(BaseConfig.PAGE, page);
        map.put(BaseConfig.PERPAGE, perpage);
        HttpManager.newInstance(activity).query(method, url, map, new HttpCallBack() {
            @Override
            public void onError(int status, String msg) {
                listener.result(status, 0, null);
            }

            @Override
            public void onResp(int status, String msg, String data) {
                if (status != 0 || data == null){
                    listener.result(status, 0, null);
                    return;
                }
                UserBeanList bean = JsonUtils.getManager().stringToBean(data, UserBeanList.class);
                int totlaPagers = bean.getTotalPage();
                List<UserBean> beanList = bean.getData();
                if (beanList != null && beanList.size() > 0){
                    listener.result(status, totlaPagers, beanList);
                }else {
                    listener.result(status, totlaPagers, null);
                }

            }
        });
    }

    /**
     * 获取一个人的粉丝 好友 关注 可一次获取多种身份的好友
     * @param type 1粉丝 2关注 3好友
     * @param cardType 身份类型 1-普通学生，2-社团，3-uni 0获取全部
     * @param uid 获取关注 粉丝时,必须传 获取好友时, 可传0
     * */
    public void getFriends(Activity activity, long uid, int page, int perpage, int type, String cardType,  final OnHttpResultListener<UserBean> listener){
        IHttpManager.RequestMethod method = null;
        String url = "";
        switch (type){
            case 1://1粉丝  2关注
                method = UserConfig.UserFans.method;
                url = UserConfig.UserFans.URL;
                break;
            case 2:
                method = UserConfig.UserFollow.method_check;
                url = UserConfig.UserFollow.URL;
                break;
            case 3://好友
                method = UserConfig.UserFriends.method;
                url = UserConfig.UserFriends.URL;
                break;
        }

        MapRequest map = new MapRequest();
        if (uid >0){
            map.put(BaseConfig.CHECK_ID, uid);
        }

        if (!TextUtils.isEmpty(cardType)){
            map.put(BaseConfig.USER_ROLE_LIST, cardType);//不传就是获取一个类别全部的
        }
        map.put(BaseConfig.PAGE, page);
        map.put(BaseConfig.PERPAGE, perpage);

        List<String> list = new ArrayList<>();
        list.add(BaseConfig.USER_ROLE_LIST);

        dataString = MapKeyObjectUtils.getUtils().decodeMap(map, list);
        HttpManager.newInstance(activity).queryString(method, url, dataString, new HttpCallBack() {
            @Override
            public void onError(int status, String msg) {
                listener.onResult(status, msg, 0, null);
            }

            @Override
            public void onResp(int status, String msg, String data) {
                if (status != 0 || data == null){
                    listener.onResult(status, msg, 0, null);
                    return;
                }
                UserBeanList bean = JsonUtils.getManager().stringToBean(data, UserBeanList.class);
                int totlaPagers = bean.getTotalPage();
                List<UserBean> beanList = bean.getData();
                if (beanList != null && beanList.size() > 0){
                    listener.onResult(status, msg, totlaPagers, beanList);
                }else {
                    listener.onResult(status, msg, totlaPagers, null);
                }

            }
        });
    }

    /**
     *获取我的想说的已读/未读 评论点赞消息 用于计数,提醒
     * @param checkCount 检查最新的通知数量,此字段为true时,获取数据后不会把未读数据标为已读
     * */
    public void getSpeekNotice(Activity activity, Boolean isRead,Boolean checkCount, int page, int perPage, final SpeekNoticeListener listener){
        MapRequest map = new MapRequest();
        if (isRead != null){
            map.put(BaseConfig.IS_READ, isRead);
        }
        map.put(BaseConfig.PAGE, page);
        map.put(BaseConfig.PERPAGE, perPage);
        if (checkCount != null){
            map.put(BaseConfig.CHECK_COUNT, checkCount);
        }

        HttpManager.newInstance(activity).query(UUConfig.SpeelNotice.method, UUConfig.SpeelNotice.URL, map, new HttpCallBack() {
            @Override
            public void onError(int status, String msg) {
                Log.d("jjf", "享说评论点赞status="+status+"=msg="+msg);
                listener.result(status, 0,0, null);
            }

            @Override
            public void onResp(int status, String msg, String data) {
                Log.d("jjf", "享说评论点赞status="+status+"=msg="+msg);
                if (status != 0){
                    listener.result(status, 0,0, null);
                    return;
                }
                if (!TextUtils.isEmpty(data) && !data.equals("[]")){
                    SpeekMsgListBean listBean = JsonUtils.getManager().stringToBean(data, SpeekMsgListBean.class);
                    if (listBean != null){
                        listener.result(status, listBean.getTotal(),listBean.getTotalPage(), listBean.getData());
                    }else {
                        listener.result(status, 0, 0,null);
                    }
                }else {
                    listener.result(status, 0,0, null);
                }
            }
        });
    }

    /**
     * 获取社团成员 默认第一位是社长
     * */
    public void getClubMembers(final Activity activity, long orgId, int page, final UsersListener listener){
        MapRequest map = new MapRequest();
        map.put(BaseConfig.PAGE, page);
        map.put(BaseConfig.PERPAGE, 20);
        map.put(BaseConfig.ORG_ID, orgId);

        HttpManager.newInstance(activity).query(ClubConfig.ClubMemeber.method, ClubConfig.ClubMemeber.URL, map, new HttpCallBack() {
            @Override
            public void onError(int status, String msg) {
                Log.d("jjf", "status="+status+"=msg="+msg);
                listener.result(status, 0, null);
                UCommonUtil.getUtil().showToast(activity, "获取失败");

            }

            @Override
            public void onResp(int status, String msg, String data) {
                Log.d("jjf", "status="+status+"=msg="+msg);
                if (status != 0){
                    listener.result(status, 0, null);
                    return;
                }

                if (!TextUtils.isEmpty(data)){
                    UserBeanList beanList = JsonUtils.getManager().stringToBean(data, UserBeanList.class);
                    if (beanList != null){
                        int totlaPagers = beanList.getTotalPage();
                        List<UserBean> list = beanList.getData();
                        listener.result(status, totlaPagers, list);
                    }
                }
            }
        });
    }

    /**
     * 根据用户ID 查询用户详细信息
     * */
    public void getUserInfo(final Activity activity, long uid, final OnHttpResultSingleListener<UserBean> listener){
        MapRequest map = new MapRequest();
        map.put(BaseConfig.ID, uid);
        HttpManager.newInstance(activity).query(UserConfig.ChangeInfo.method_check, UserConfig.ChangeInfo.URL, map, new HttpCallBack() {
            @Override
            public void onError(int status, String msg) {
                listener.onResult(status, msg, null);
            }

            @Override
            public void onResp(int status, String msg, String data) {
                if (status == 0){
                    if (TextUtils.isEmpty(data)){
                        listener.onResult(status, msg, null);
                        return;
                    }
                    UserBean userBean = JsonUtils.getManager().stringToBean(data, UserBean.class);
                    listener.onResult(status, msg, userBean);
                }else {
                    listener.onResult(status, msg, null);
                }
            }
        });
    }

    /**
     * 根据班级ID查询班级的信息 也可以判断班级是否有新成员加入
     * */
//    public void checkClassInfo(Activity activity, long classId, final ClassInfoListener listener){
//        MapRequest map = new MapRequest();
//        map.put(BaseConfig.CLASS_ID, classId);
//        HttpManager.newInstance(activity).query(UniConfig.GetClassInfo.method, UniConfig.GetClassInfo.URL, map, new HttpCallBack() {
//            @Override
//            public void onError(int status, String msg) {
//                Log.d("jjf", "获取班级信息=stutas="+status+"=msg="+msg);
//                listener.result(status, null);
//            }
//
//            @Override
//            public void onResp(int status, String msg, String data) {
//                Log.d("jjf", "获取班级信息=stutas="+status+"=data="+data);
//                if (status != 0){
//                    listener.result(status, null);
//                }
//                if (!TextUtils.isEmpty(data)){
//                    AuthenStudentBean bean = JsonUtils.getManager().stringToBean(data, AuthenStudentBean.class);
//                    if (bean != null){
//                        listener.result(status, bean);
//                    }else {
//                        listener.result(status, null);
//                    }
//                }else {
//                    listener.result(status, null);
//                }
//            }
//        });
//
//    }

    /**
     * 社团社长获取自己是否有未读的纳新信息
     * */
    public void getClubNoRead(Activity activity, final BaseListener listener){
        MapRequest map = new MapRequest();
        HttpManager.newInstance(activity).query(ClubConfig.GetClubNoRead.method, ClubConfig.GetClubNoRead.URL, null, new HttpCallBack() {
            @Override
            public void onError(int status, String msg) {
                Log.d("jjf", "社团纳新=stutas="+status+"=msg="+msg);
                listener.result(status, null);
            }

            @Override
            public void onResp(int status, String msg, String data) {
                Log.d("jjf", "社团纳新=stutas="+status+"=data="+data);
                if (status == 0 && !TextUtils.isEmpty(data)){
                    RecruitUnreadBean bean = JsonUtils.getManager().stringToBean(data, RecruitUnreadBean.class);
                    listener.result(status, bean);
                }else {
                    listener.result(status, null);
                }
            }
        });
    }

    /**
     * 获取我的发布待审核数据
     * */
    public void getMyReleaseWait(Activity activity, int page, String muti, OnHttpResultListener<UcityInfoBean> listener){
        getMyRelease(activity, 0, page, 10, muti, listener);
    }

    /**
     * 获取我的发布通过数据
     * */
    public void getMyReleasePass(Activity activity, int page, String muti, OnHttpResultListener<UcityInfoBean> listener){
        getMyRelease(activity, 1, page, 10, muti, listener);
    }

    /**
     * 获取我的发布不通过数据
     * */
    public void getMyReleaseRefuse(Activity activity, int page, String muti, OnHttpResultListener<UcityInfoBean> listener){
        getMyRelease(activity, 2, page, 10, muti, listener);
    }



    private  List<String> list;
    private String dataString;
    /**
     * 获取我的发布 examineType 0=未审核 1=通过 2=不通过
     * @param mutiType 获取几种类型的信息 如 "1,2,3"
     * */
    public void getMyRelease(final Activity activity, int examineType, int page, int perPage, String mutiType, final OnHttpResultListener<UcityInfoBean> listener){
        MapRequest map = new MapRequest();
        map.put(BaseConfig.IS_EXAMINE, examineType);
        map.put(BaseConfig.PAGE, page);
        map.put(BaseConfig.PERPAGE, perPage);
        if (!TextUtils.isEmpty(mutiType)){
            map.put(BaseConfig.MUTI_TYPE, mutiType);
        }else {
            String muti = "";
            switch (UChengApplication.userRole){
                case BaseConfig.CLUB_ROLE:
                    muti = "1,2,3,5,8";
                    break;
                default:
                    break;
            }
            if (!TextUtils.isEmpty(muti)){
                map.put(BaseConfig.MUTI_TYPE, muti);
            }
        }
        if (list == null){
            list = new ArrayList<>();
        }
        list.add(BaseConfig.MUTI_TYPE);
        dataString = MapKeyObjectUtils.getUtils().decodeMap(map, list);

        HttpManager.newInstance(activity).queryString(UCityConfig.GetMyRelease.method, UCityConfig.GetMyRelease.URL, dataString, new HttpCallBack() {
            @Override
            public void onError(int status, String msg) {
                Log.d("jjf", "status="+status+"=msg="+msg);
                UCommonUtil.getUtil().showToast(activity, "获取信息失败");
                listener.onResult(status, msg, 0, null);
            }

            @Override
            public void onResp(int status, String msg, String data) {
                Log.d("jjf", "status="+status+"=msg="+msg);
                if (status != 0){
                    listener.onResult(status, msg, 0, null);
                    UCommonUtil.getUtil().showToast(activity, msg);
                    return;
                }
                if (!TextUtils.isEmpty(data) && !data.equals("[]")){
                    UcityBean bean = JsonUtils.getManager().stringToBean(data, UcityBean.class);
                    List<UcityInfoBean> listBean = bean.getData();
                    listener.onResult(status, msg, bean.getTotalPage(), listBean);
                }
            }
        });

    }

    /**
     * 获取系统审核信息 暂时只有我的发布信息审核反馈
     * */
    public void getReleaseFeedback(final Activity activity, int page, final OnHttpResultListener<UcityInfoBean> listener){
        MapRequest map = new MapRequest();
        map.put(BaseConfig.PAGE, page);
        map.put(BaseConfig.PERPAGE, 10);
        String muti = "1,2";
        if (!TextUtils.isEmpty(muti)){
            map.put(BaseConfig.EXAMINE_STATUS, muti);
        }
        if (list == null){
            list = new ArrayList<>();
        }
        list.add(BaseConfig.EXAMINE_STATUS);
        dataString = MapKeyObjectUtils.getUtils().decodeMap(map, list);

        HttpManager.newInstance(activity).queryString(UCityConfig.GetMyRelease.method, UCityConfig.GetMyRelease.URL, dataString, new HttpCallBack() {
            @Override
            public void onError(int status, String msg) {
                Log.d("jjf", "status="+status+"=msg="+msg);
                UCommonUtil.getUtil().showToast(activity, "获取信息失败");
                listener.onResult(status, msg, 0, null);
            }

            @Override
            public void onResp(int status, String msg, String data) {
                Log.d("jjf", "status="+status+"=msg="+msg);
                if (status != 0){
                    listener.onResult(status, msg, 0, null);
                    UCommonUtil.getUtil().showToast(activity, msg);
                    return;
                }
                if (!TextUtils.isEmpty(data) && !data.equals("[]")){
                    UcityBean bean = JsonUtils.getManager().stringToBean(data, UcityBean.class);
                    List<UcityInfoBean> listBean = bean.getData();
                    listener.onResult(status, msg, bean.getTotalPage(), listBean);
                }
            }
        });

    }

    /**
     * 获取我创建或者加入的社团
     * */
    public void getMyClub(Activity activity, boolean isCreate, int page, int perPage, final OnHttpResultListener<SchoolClubBean> listener){
        IHttpManager.RequestMethod method = null;
        String url = "";
        if (isCreate){
            //我创建的社团
            method = UserConfig.MyClubs.method;
            url = UserConfig.MyClubs.URL;
        }else {
            method = UserConfig.JoinClub.method;
            url = UserConfig.JoinClub.URL;
        }
        MapRequest map = new MapRequest();
        map.put(BaseConfig.PAGE, page);
        map.put(BaseConfig.PERPAGE, perPage);
        HttpManager.newInstance(activity).query(method, url, map, new HttpCallBack() {
            @Override
            public void onError(int status, String msg) {
                listener.onResult(status, msg, 0, null);
            }

            @Override
            public void onResp(int status, String msg, String data) {
                if (status == 0 && !TextUtils.isEmpty(data) && !data.equals("[]")){
                    ClubListBean bean = JsonUtils.getManager().stringToBean(data, ClubListBean.class);
                    listener.onResult(status,msg, bean.getTotalPage(), bean.getData());
                }else {
                    listener.onResult(status, msg, 0, null);
                }
            }
        });
    }

    /**
     * 获取关联账号
     * */
    public void getLinkAccount(Activity activity, final OnHttpResultListener<LinkAccountBean> listener){
        LoadingUtils.getUtils().loading(activity);
        MapRequest map = new MapRequest();
        HttpManager.newInstance(activity).query(AccountConfig.Link.method_get, AccountConfig.Link.URL, map, new HttpCallBack() {
            @Override
            public void onError(int status, String msg) {
                LoadingUtils.getUtils().hide();
                listener.onResult(status, msg, 0, null);
            }

            @Override
            public void onResp(int status, String msg, String data) {
                LoadingUtils.getUtils().hide();
                if (status ==0 && !TextUtils.isEmpty(data)){
                    List<LinkAccountBean> list = JsonUtils.getManager().parseList(data, LinkAccountBean.class);
                    listener.onResult(status, msg, 0, list);
                }else {
                    listener.onResult(status, msg, 0, null);
                }
            }
        });
    }

    /**
     * 关联一个账号
     * @param userAccount 账号
     * @param userPw 密码
     * */
    public void linkAccount(Activity activity, String userAccount, String userPw, final OnHttpResultSingleListener<LinkAccountBean> listener){
        LoadingUtils.getUtils().loading(activity);
        MapRequest map = new MapRequest();
        map.put(BaseConfig.USER_NAME, userAccount);
        map.put(BaseConfig.USER_PWD, MD5.md5(userPw));
        HttpManager.newInstance(activity).query(AccountConfig.Link.method_post, AccountConfig.Link.URL, map, new HttpCallBack() {
            @Override
            public void onError(int status, String msg) {
                LoadingUtils.getUtils().hide();
                listener.onResult(status, msg, null);
            }

            @Override
            public void onResp(int status, String msg, String data) {
                LoadingUtils.getUtils().hide();
                if (status ==0 && !TextUtils.isEmpty(data)){
                    LinkAccountBean bean = JsonUtils.getManager().stringToBean(data, LinkAccountBean.class);
                    listener.onResult(status, msg, bean);
                }else {
                    listener.onResult(status, msg, null);
                }
            }
        });

    }

    /**
     * 点击邀请注册
     * */
    public void inviteRgister(Activity activity, String mobile, final OnResultListener listener){
        LoadingUtils.getUtils().loading(activity);
        MapRequest map = new MapRequest();
        map.put(BaseConfig.MOBILE, mobile);
        HttpManager.newInstance(activity).query(IHttpManager.RequestMethod.POST, UserConfig.USER_INVITE_MSG, map, new HttpCallBack() {
            @Override
            public void onError(int status, String msg) {
                LoadingUtils.getUtils().hide();
                listener.onResult(status, msg, 0, null);
            }

            @Override
            public void onResp(int status, String msg, String data) {
                LoadingUtils.getUtils().hide();
                listener.onResult(status, msg, 0, null);
            }
        });
    }


    public interface GroupInfiListener{
        void result(int stutas, GroupBean bean);
    }

    public interface UserInfoListener{
        void result(int stutas, UserBean bean);
    }

//    public interface ClassInfoListener{
//        void result(int stutas, AuthenStudentBean bean);
//    }

    public interface BaseListener{
        void result(int stutas, BaseBean bean);
    }


    public interface AttenListener{
        void atten(int status);
    }

    public interface UsersListener{
        void result(int status, int count, List<UserBean> list);
    }

    public interface SpeekNoticeListener{
        void result(int stutas, int count,int tatolPage,  List<SpeekMsgBean> been);
    }

    public interface CheckMyCountListener{
        void onResult(int fansNum, int followNum, int friendNum);
    }


}
